<div class="user-center-head"><?php echo L('new_address')?></div>
<form action ="<?php echo url('user/address_edit', array('aid' => isset($address['id']) ? $address['id'] : null));?>" method="post" id="addressForm">
  <ul class="user-center-fields">
    <li>
      <em><?php echo L('fristname')?>:</em>
      <input type="text" name="delivery_first_name" id="delivery_first_name" value="<?php echo isset($address['delivery_first_name']) ? $address['delivery_first_name'] : null?>" class="required" alt="<?php echo L('inputfristname');?>" />
    </li>
    <li>
      <em><?php echo L('state')?>:</em>
      <input type="text" name="delivery_province" id="delivery_province" value="<?php echo isset($address['delivery_province']) ? $address['delivery_province'] : null?>" class="required" alt="<?php echo L('inputstate')?>" />
    </li>
    <li>
      <em><?php echo L('city')?>:</em>
      <input type="text" name="delivery_city" id="delivery_city" value="<?php echo isset($address['delivery_city']) ? $address['delivery_city'] : null?>" class="required" alt="<?php echo L('inputcity')?>" />
    </li>
    <li>
      <em><?php echo L('_STREET_LINE1_');?>:</em>
      <input type="text" name="delivery_address" id="delivery_address" value="<?php echo isset($address['delivery_address']) ? $address['delivery_address'] : null?>" class="required" alt="<?php echo L('inputaddress')?>" />
    </li>
    <li>
      <em><?php echo L('_STREET_LINE2_');?>:</em>
      <input type="text" name="delivery_address2" value="<?php echo isset($address['delivery_address2']) ? $address['delivery_address2'] : null?>" class="required" />
    </li>
    <li>
      <em><?php echo L('phone')?>:</em>
      <input type="text" id="delivery_phone" name="delivery_phone" value="<?php echo isset($address['delivery_phone']) ? $address['delivery_phone'] : null?>" class="required" alt="<?php echo L('inputphone')?>" />
    </li>
    <li>
      <em><?php echo L('email')?>:</em>
      <input type="text" name="delivery_email" id="delivery_email" value="<?php echo isset($address['delivery_email']) ? $address['delivery_email'] : null?>" class="required" alt="<?php echo L('inputemail')?>" />
    </li>
    <li style="width:100%;">
      <label class="text"><input type="checkbox" name="default" value="1" checked style="margin-right:.3em;vertical-align:middle;" /><?php echo L('default')?></label>
    </li>
    <li>
      <input type="hidden" name="address_id" value="<?php echo isset($address['id']) ? $address['id'] : 0;?>" />
      <input type="submit" name="dosubmit" value="<?php echo L('saveuser')?>" class="btn" />
    </li>
  </ul>
</form>
<script>
$(function() {
  $('select[name=delivery_cid]').on('change', function() {
    $(this).prev().text($(this).find('option:selected').text());
  });
  var addressForm = $("#addressForm"),
  addressValidator = addressForm.validate({ //地址验证
    errorElement: 'p',
    submitHandler: function(form) {
      form.submit();
    },
    errorPlacement: function(error, element) {
      element.after(error).addClass('error');
    },
    success: function(label) {
      label.removeClass('error');
    },
    rules: {
      delivery_phone: {
        required: true
      },
      delivery_email: {
        required: true,
        email: true
      }
    }
  });
});
</script>